package org.onepiece.admin.common.config.yaml;

import org.springframework.boot.env.YamlPropertySourceLoader;
import org.springframework.core.env.PropertySource;
import org.springframework.core.io.support.DefaultPropertySourceFactory;
import org.springframework.core.io.support.EncodedResource;

import java.io.IOException;

/**
 * Created by IntelliJ IDEA.
 *
 * @author zhujianke@gaodun.com
 * @since 2022/10/28 13:27
 */
public class YamlPropertySourceFactory extends DefaultPropertySourceFactory {

    public YamlPropertySourceFactory() {
    }

    @Override
    public PropertySource<?> createPropertySource(String name, EncodedResource resource) throws IOException {
        return (new YamlPropertySourceLoader()).load(resource.getResource().getFilename(), resource.getResource()).get(0);
    }
}
